package cn.gym.service;

import cn.gym.dao.UserMapper;
import cn.gym.pojo.User;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
@Service("userService")
public class UserServiceImpl implements UserService {
    @Resource
    private UserMapper userMapper;

    public UserMapper getUserMapper() {
        return userMapper;
    }

    public void setUserMapper(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    @Override
    public User doLoin(User user) {
        User login=null;
        try{
            login=userMapper.doLogin(user);
        }catch (Exception e){
            e.printStackTrace();
        }
        return login;
    }

    @Override
    public boolean register(User user) {
        int isReg=0;
        boolean flag=false;
        try {
            isReg=userMapper.insert(user);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if(isReg>0){
            flag=true;
        }
        return flag;
    }

    @Override
    public int selectByUserCode(String userCode) {

        return 0;
    }
}
